<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Upload extends Admin_Controller {
    public function __construct(){
        parent::__construct();
    }
    public function upload_action(){
        //得到上传的临时文件流
        $webmaster_config = $this->config->item('webmaster'); 
        $root     		  = $webmaster_config['root'];
		$tempFile 		  = $_FILES['Filedata']['tmp_name'];
		$fileTypes 		  = array('jpg','jpeg','gif','png'); 
		$fileName 		  = iconv("UTF-8","GB2312",$_FILES["Filedata"]["name"]);
		$ext_name         = get_ext_name($fileName);
		$file     		  = microtime();
		$new_file		  = $file.'.'.$ext_name;
		$new_file		  = str_replace(array(' '), array(''), $new_file);
		$fileParts		  = pathinfo($_FILES['Filedata']['name']);
		$files			  = $_POST['typeCode'];
		if(!in_array($ext_name, $fileTypes)){
			echo '请上传图片文件';
			exit;
		}
		if (move_uploaded_file($tempFile, $root.'/static/temp/'.$new_file)){
			echo '/static/temp/'.$new_file;
		}else{
			echo $fileName."上传失败！";
		}
    }
}
?>